home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / samples / midpnt / songinfo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-14  |  4.5 KB  |  193 lines

  1. /*
  2.  *      SongInfo.cpp
  3.  *
  4.  * MIDAS Module Player for Windows NT Song Information View
  5.  *
  6.  * $Id: SongInfo.cpp 1.3 1997/01/14 17:42:08 pekangas Exp $
  7.  *
  8.  * Copyright 1996 Petteri Kangaslampi
  9. */
  10.  
  11. #define WIN32_LEAN_AND_MEAN
  12. #include <windows.h>
  13. #include "midasdll.h"
  14. #include "MidpView.h"
  15. #include "MidpNT.h"
  16. #include "MidpModeless.h"
  17. #include "SongInfo.h"
  18. #include "MidpRes.h"
  19. #include "ViewList.h"
  20.  
  21.  
  22. static BOOL CALLBACK DialogProc(HWND hwnd, UINT message, WPARAM wparam,
  23.     LPARAM lparam);
  24.  
  25.  
  26.  
  27. SongInfoView::SongInfoView(void)
  28. {
  29.     window = NULL;
  30. }
  31.  
  32.  
  33. SongInfoView::~SongInfoView(void)
  34. {
  35.     if ( window != NULL )
  36.     {
  37.         delete window;
  38.         window = NULL;
  39.     }
  40. }
  41.  
  42.  
  43. char *SongInfoView::Name(void)
  44. {
  45.     return "SongInfoView";
  46. }
  47.  
  48.  
  49. char *SongInfoView::Description(void)
  50. {
  51.     return "Song Information";
  52. }
  53.  
  54.  
  55. midpViewWindow *SongInfoView::CreateViewWindow(Registry *registry)
  56. {
  57.     if ( window != NULL )
  58.         return (midpViewWindow*) window;
  59.     window = new SongInfoWindow(0, this, registry);
  60.     return (midpViewWindow*) window;
  61. }
  62.  
  63.  
  64. void SongInfoView::DestroyViewWindow(midpViewWindow *_window)
  65. {
  66.     if ( _window != window )
  67.         Panic("SongInfoView::DestroyWindow: _window != window");
  68.  
  69.     delete window;
  70.     window = NULL;
  71. }
  72.  
  73.  
  74.  
  75.  
  76. SongInfoWindow::SongInfoWindow(int instanceNumber, midpView *view,
  77.     Registry *registry) :
  78.     midpViewWindow(instanceNumber, view, registry)
  79. {
  80.     HWND        parent = NULL;
  81.  
  82.     if ( viewsChildren )
  83.         parent = mainWinHandle;
  84.  
  85.     instanceNumber = instanceNumber;
  86. //    modeless.hwnd = hwnd = CreateDialogParam(instance, "SONGINFO", NULL,
  87. //        (DLGPROC) DialogProc, (LPARAM) this);
  88.  
  89.     modeless.hwnd = hwnd = CreateDialogParam(instance, "SONGINFO",
  90.         parent, (DLGPROC) DialogProc, (LPARAM) this);
  91.  
  92.     midpModelessList.AddItem(&modeless);
  93.     viewWindowList.AddWindow(this);
  94. }
  95.  
  96.  
  97.  
  98. SongInfoWindow::~SongInfoWindow(void)
  99. {
  100.     viewWindowList.RemoveWindow(this);
  101.     midpModelessList.RemoveItem(&modeless);
  102.     DestroyWindow(hwnd);
  103. }
  104.  
  105.  
  106.  
  107. static BOOL CALLBACK DialogProc(HWND hwnd, UINT message, WPARAM wparam,
  108.     LPARAM lparam)
  109. {
  110.     SongInfoWindow *window;
  111.  
  112.     if ( message == WM_INITDIALOG )
  113.             SetWindowLong(hwnd, GWL_USERDATA, lparam);
  114.  
  115.     window = (SongInfoWindow*) GetWindowLong(hwnd, GWL_USERDATA);
  116.  
  117.     return window->ClassDialogProc(hwnd, message, wparam, lparam);
  118. }
  119.  
  120.  
  121. BOOL CALLBACK SongInfoWindow::ClassDialogProc(HWND hwnd, UINT message,
  122.     WPARAM wparam, LPARAM lparam)
  123. {
  124.     hwnd = hwnd;
  125.     wparam = wparam;
  126.     lparam = lparam;
  127.  
  128.     switch ( message )
  129.     {
  130.         case WM_INITDIALOG:
  131.             this->hwnd = hwnd;
  132.             SendDlgItemMessage(hwnd, SONGINFO_SONG, EM_LIMITTEXT, 255, 0);
  133.             SendDlgItemMessage(hwnd, SONGINFO_COMPOSER, EM_LIMITTEXT, 255, 0);
  134.             SendDlgItemMessage(hwnd, SONGINFO_COMMENT, EM_LIMITTEXT, 255, 0);
  135.             UpdateInfo();
  136.             SendDlgItemMessage(hwnd, SONGINFO_SONG, EM_SETSEL, (unsigned) -1,
  137.                 255);
  138.             SetWindowPos(hwnd, NULL, 0, 0, 17, 42, SWP_NOSIZE | SWP_NOREDRAW
  139.                  | SWP_NOZORDER | SWP_NOACTIVATE);
  140.             if ( startX != CW_USEDEFAULT )
  141.                 SetWindowPos(hwnd, NULL, startX, startY, 17, 42,
  142.                     SWP_NOSIZE | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOACTIVATE);
  143.             return TRUE;
  144.  
  145.         case WM_CLOSE:
  146.             ownerView->DestroyViewWindow(this);
  147.             return TRUE;
  148.  
  149.         case MIDPMSG_SONGCHANGED:
  150.             UpdateInfo();
  151.             return TRUE;
  152.  
  153.         case WM_COMMAND:
  154.             switch ( LOWORD(wparam) )
  155.             {
  156.                 case IDCANCEL:
  157.                     ownerView->DestroyViewWindow(this);
  158.                     return TRUE;
  159.             }
  160.  
  161.     }
  162.  
  163.     return FALSE;
  164. }
  165.  
  166.  
  167. void SongInfoWindow::UpdateInfo(void)
  168. {
  169.     MIDASmoduleInfo moduleInfo;
  170.  
  171.     if ( module != NULL )
  172.     {
  173.         MIDASgetModuleInfo(module, &moduleInfo);
  174.         SendDlgItemMessage(hwnd, SONGINFO_SONG, WM_SETTEXT, 0,
  175.             (LPARAM)(LPCTSTR) moduleInfo.songName);
  176.     }
  177.     else
  178.     {
  179.         SendDlgItemMessage(hwnd, SONGINFO_SONG, WM_SETTEXT, 0,
  180.             (LPARAM)(LPCTSTR) "[none]");
  181.     }
  182. }
  183.  
  184.  
  185. /*
  186.  * $Log: SongInfo.cpp $
  187.  * Revision 1.3  1997/01/14 17:42:08  pekangas
  188.  * Changed to use MIDAS DLL API
  189.  *
  190.  * Revision 1.2  1996/07/16 19:22:16  pekangas
  191.  * Removed Visual C warnings, added RCS keywords, converted to LFs
  192.  *
  193. */